package com.zxl.designpattern.behavioral.responsibilitychain;

/**
 * 主类，演示责任链模式的使用
 */
public class Test {
    public static void main(String[] args) {
        // 创建审核处理器链
        PostHandler spamHandler = new SpamHandler();
        PostHandler contentHandler = new ContentHandler();
        PostHandler imageHandler = new ImageHandler();
        PostHandler linkHandler = new LinkHandler();
        
        // 构建责任链
        spamHandler.setNext(contentHandler)
                   .setNext(imageHandler)
                   .setNext(linkHandler);
        
        // 创建测试帖子
        Post post1 = new Post("这是一篇正常的帖子，讨论技术问题", "张三", false, false);
        Post post2 = new Post("这是一篇包含广告的帖子，推销产品", "李四", false, false);
        Post post3 = new Post("这是一篇包含违规词汇的帖子，涉及色情内容", "王五", false, false);
        Post post4 = new Post("这是一篇包含图片的帖子", "赵六", true, false);
        Post post5 = new Post("这是一篇包含恶意链接的帖子 http://malicious.com", "钱七", false, true);
        
        // 测试帖子审核
        System.out.println("=== 审核帖子1 ===");
        spamHandler.handle(post1);
        System.out.println(post1);
        
        System.out.println("\n=== 审核帖子2 ===");
        spamHandler.handle(post2);
        System.out.println(post2);
        
        System.out.println("\n=== 审核帖子3 ===");
        spamHandler.handle(post3);
        System.out.println(post3);
        
        System.out.println("\n=== 审核帖子4 ===");
        spamHandler.handle(post4);
        System.out.println(post4);
        
        System.out.println("\n=== 审核帖子5 ===");
        spamHandler.handle(post5);
        System.out.println(post5);
    }
}    